<?php
/**
 * 登录类
 *
 */
class LoginAction extends Action
{
	public function chklogin()
	{
		if(!isset($_SESSION['member']))
		{
			$this->redirect('Login/login');
		}
	}
	
	
	public function login()
	{
		if(isset($_SESSION['member']))
		{
			unset($_SESSION['member']);
		}
		
		$this->display();
	}
	
	public function check()
	{
		$data['username'] = $_POST['username'];
		$data['password'] = md5($_POST['password']);
		$where['username'] = array('eq',$data['username']);
		$where['password'] = array('eq',$data['password']);
		
		$DB = M('admin');
		$menber = $DB->where($where)->find();
		if($menber){
			$_SESSION['member'] = $menber;
			$this->redirect('Index/index','',1,'登录成功，转向后台中心');
		}else
		{
			$this->redirect('login','',1,'用户名或密码错误，请重新输入');
		}
	}
}